﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="News.aspx.cs" Inherits="Ym.print.News" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../js/jquery.pagination.js" type="text/javascript"></script>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/pagination.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function() {
	        //分页参数设置
	        $("#page").pagination(<%=pcount %>, {
		        callback: pageselectCallback,
		        prev_text: "上一页",
		        next_text: "下一页",
		        items_per_page:<%=pagesize %>,
		        current_page:<%=page %>,
		        link_to:"?page=__id__"
	        });
            $(".msgtable tr:nth-child(odd)").addClass("tr_bg"); //隔行变色
            $(".msgtable tr").hover(
			    function() {
			        $(this).addClass("tr_hover_col");
			    },
			    function() {
			        $(this).removeClass("tr_hover_col");
			    }
		    );
        });
        function pageselectCallback(page_id, jq) {
           //alert(page_id); 回调函数，进一步使用请参阅说明文档
        }
        function del(i){
            var r=confirm("确认删除记录吗？");
            if(r){
                $.ajax({
	                type: "post",
	                url: "DoAjax.ashx",
	                data: "act=delNews&id=" + i,
	                beforeSend: function () { },
	                success: function (msg) {
		                if(msg == "1"){
			                parent.jsprint("删除成功","Success");location.reload();
		                }else{
                            parent.jsprint("删除失败","Error");location.reload();
		                }
	                },
	                complete: function () { },
	                error: function () { parent.jsprint("网络繁忙，请稍后再试！","Error"); }
                })
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
    <asp:Repeater ID="NewsRpt" runat="server">
        <HeaderTemplate>
        <table width="95%" cellpadding="0" cellspacing="1" border="0" class="msgtable">
            <tr>
                <th width="3%">序号</th>
                <th class="left">常识标题</th>
                <th width="60">点击量</th>
                <th width="60">添加日期</th>
                <th width="70">操作</th>
            </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td style="width:3%"><%# Container.ItemIndex + 1 %></td>
                <td class="left"><a href="NewsEdit.aspx?id=<%# Eval("Id") %>"><%# Eval("NTitle")%></a></td>
                <td><%# Eval("NHit")%></td>
                <td><%# ((DateTime)Eval("NTime")).ToString("yyyy-MM-dd") %></td>
                <td>
                    <a href="NewsEdit.aspx?id=<%# Eval("Id") %>">修改</a>
                    <a href="javascript:del(<%# Eval("Id") %>);">删除</a>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            <tr>
                <td class="add"><input type="button" value="添 加" onclick="location.href='NewsEdit.aspx'" class="l-button" /></td>
                <td class="page nom" align="center" colspan="4" id="page"></td>
            </tr>
        </table>
        </FooterTemplate>
        </asp:Repeater>
    </div>
    </form>
</body>
</html>
